<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="org.springframework.web.servlet.ModelAndView"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@ page import="geeks.modelo.Persona, geeks.modelo.Rol, geeks.modelo.CentroFormacion"%>
<%@ page import="geeks.negocio.GestionPersonas, geeks.negocio.GestionRol, geeks.negocio.GestionCentroFormacion" %>

<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Collection"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
    
	<title>Mantenimiento de Usuarios</title>
	
	<script>
		function redireccionar(url)
  		{
  			document.f1.action = url;
        	document.f1.submit();	        
 		}
	</script>	
</head>
<body>
	<div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="#">Project name</a>
          <div class="nav-collapse">
            <ul class="nav">
              <li class="active"><a href="#">Home</a></li>
              <li><a href="#about">About</a></li>
              <li><a href="#contact">Contact</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>
    
	<section class="container">
    	<div class="row">
        	<div class="span12">
                <form name="f1" action="" method="post">
                    <section>
                        <p>
                            <div><strong>MANTENIMIENTO DE USUARIOS</strong></div>
                        </p>
                        <p>
                            <div><input type="button" class="boton" value="Registrar Usuario" onClick="return redireccionar('manttoUsuarios.html?v=1');"></div>                        </p>
                        <p>
                            <c:set var="palabra" value="${requestScope['PALABRA']}"/>
                            <div>Buscar por apellido: 						
                                <input name="txtPalabra" value="${palabra }" title="Debe ingresar un apellido para buscar" onKeyPress="buscarUsuarios.html" required autofocus/>
                                <input type="button" class="boton" value="Buscar" onClick="return redireccionar('buscarUsuarios.html');" title="Haga clic aqu&iacute; para buscar por el criterio ingresado">                        
                            </div>
                        </p>
                        <p>
                            <div>
                                <strong>Lista de Usuarios</strong>
                            </div>					
                        </p>
                        <div>
                            <c:set var="resultado" value="${requestScope['RESULTADO']}"/>
                            <div id="mensaje-ok">${resultado }</div>
                            <c:set var="error" value="${requestScope['ERROR']}"/>
                            <div id="mensaje-error">${error }</div>
                        </div>
                        <table border="1" class="tableborder">				
                            <tr class="grilla_cabecera">
                                <th>Codigo</th>
                                <th>Nombres y Apellidos</th>					
                                <th>Tipo Documento</th>
                                <th>Nro. Documento</th>
                                <th>Sexo</th>
                                <th>Email</th>
                                <th>Celular</th>
                                <th>Centro de Formaci&oacute;n</th>
                                <th>Rol</th>
                                <th colspan="2">Acciones</th>
                            </tr>
                            <tr>
                            <%
                                Collection<Persona> lista = (ArrayList<Persona>)request.getAttribute("LISTA"); 
                                
                                for(Persona obj : lista){ %>
                                    <td> <%= obj.getIdPersona() %> </td>
                                    <td align="center"> <%= obj.getNombre() + " " + obj.getApePaterno() + " " + obj.getApeMaterno() %> </td>
                                    <td> <%= obj.getTipoDocumento() %> </td>
                                    <td> <%= obj.getNumDocumento() %></td>
                                    <td> <%= obj.getSexo() %> </td>
                                    <td> <%= obj.getEmail() %></td>
                                    <td> <%= obj.getCelular() %></td>
                                    
                                    <% GestionCentroFormacion negCF = new GestionCentroFormacion(); 
                                    
                                    CentroFormacion cf = negCF.obtener(obj.getIdCentroFormacion()); %>
                                    
                                    <td> <%= cf.getNombre() %></td>
                                    
                                    <% GestionRol negRol = new GestionRol();
                                    
                                    Rol rol = negRol.buscarRol(obj.getRol().getIdRol()); %>
                                    
                                    <td> <%= rol.getDescRol() %></td>		
                                                    
                                    <td><a href="manttoUsuarios.html?v=2&id=<%= obj.getIdPersona()%>"><img
							src="img/editar.jpg" alt="" title="" border="0" /></a></td>				   
                                    <td><a href="eliminarUsuario.html?id=<%=obj.getIdPersona()%>" onclick="return confirm('Est&aacute; seguro que desea eliminar?', 'Sistema Gestion de Innovacion');"><img
							src="img/delete.gif" alt="" title="" border="0"/></a></td>
                           </tr>
                           <%
                           }
                           %>
                           
                        </table>
                        <p>
                        <div><input type="button" class="boton" value="Atr&aacute;s" onclick="return redireccionar('validar.html');"></div>
                        </p>
                    </section>		
                </form>
        	</div>
     	</div>
        <footer>
        <p>Copyright &copy; 2013  Geeks</p>
      	</footer>
	</section>
    
    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->

	<script src="js/jquery-1.7.2.min.js"></script>
    <script src="js/bootstrap-transition.js"></script>
    <script src="js/bootstrap-alert.js"></script>
    <script src="js/bootstrap-modal.js"></script>
    <script src="js/bootstrap-dropdown.js"></script>
    <script src="js/bootstrap-scrollspy.js"></script>
    <script src="js/bootstrap-tab.js"></script>
    <script src="js/bootstrap-tooltip.js"></script>
    <script src="js/bootstrap-popover.js"></script>
    <script src="js/bootstrap-button.js"></script>
    <script src="js/bootstrap-collapse.js"></script>
    <script src="js/bootstrap-carousel.js"></script>
    <script src="js/bootstrap-typeahead.js"></script>
</body>
</html>